#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 3e5 + 10;
int arr[N];
const int mod = 1e9 + 7;
int n, m, k;
priority_queue<int, vector<int>, greater<int>>down;
priority_queue<int>up;
int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (down.empty()||x<=down.top()) {
			down.push(x);
		}
		else {
			up.push(x);
		}
		if (down.size() > up.size() + 1) {
			up.push(down.top());
			down.pop();
		}
		if (up.size() > down.size()) {
			down.push(up.top());
			up.pop();
		}
	}
	//cout << up.size() + down.size() << endl;
	while (k--) {
		int a = up.top();
		if (a < m) {
			continue;
		}
		int b = down.top();
		down.pop();
		up.pop();
		down.push(b + m);
		up.push(a - m);
		if (b + m > up.top()) {
			down.push(up.top());
			up.pop();
		}
		if (a - m < down.top()) {
			up.push(down.top());
			down.pop();
		}
		if (down.size() > up.size() + 1) {
			up.push(down.top());
			down.pop();
		}
		if (up.size() > down.size()) {
			down.push(up.top());
			up.pop();
		}
	}
	//cout << up.size() + down.size() << endl;
	LL ans = 1;
	while (up.size()) {
		ans = (ans * up.top() % mod) % mod;
		cout << up.top() << " ";
		up.pop();
	}
	while (down.size()) {
		ans = (ans * down.top() % mod) % mod;
		cout << down.top() << " ";
		down.pop();
	}
	cout << ans << endl;
	return 0;
}